/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
 **********************************************************************/

#include "dik.h"
#include <QIcon>
#include <util/core/util.h>
#include "document.h"

namespace SailmiPIM
{
namespace Plugin::DocView
{
namespace Dik
{
	void Plugin::Init (ICoreProxy_ptr)
	{
        Util::InstallTranslator ("docview_dik");
	}

	void Plugin::SecondInit ()
	{
	}

	QByteArray Plugin::GetUniqueID () const
	{
		return "com.sailmi.pim.plugin.DocView.Dik";
	}

	void Plugin::Release ()
	{
	}

	QString Plugin::GetName () const
	{
        return "DocView Dik";
	}

	QString Plugin::GetInfo () const
	{
		return tr ("MOBI backend for Monocle.");
	}

	QIcon Plugin::GetIcon () const
	{
		return QIcon ();
	}

	QSet<QByteArray> Plugin::GetPluginClasses () const
	{
		QSet<QByteArray> result;
		result << "com.sailmi.pim.plugin.DocView.IBackendPlugin";
		return result;
	}

	auto Plugin::CanLoadDocument (const QString& file) -> LoadCheckResult
	{
		const auto& lower = file.toLower ();
		const bool isGood = lower.endsWith (".mobi") ||
				lower.endsWith (".prc");
		return isGood ?
				LoadCheckResult::Can :
				LoadCheckResult::Cannot;
	}

	IDocument_ptr Plugin::LoadDocument (const QString& file)
	{
		return IDocument_ptr (new Document (file, this));
	}

	QStringList Plugin::GetSupportedMimes () const
	{
		return { "application/x-mobipocket-ebook", "application/x-mobipocket" };
	}

	QList<IKnowFileExtensions::ExtInfo> Plugin::GetKnownFileExtensions () const
	{
		return
		{
			{
				tr ("MOBI books"),
				{ "mobi" }
			}
		};
	}
}
}
}

SAILMIPIM_EXPORT_PLUGIN (sailmipim_docview_dik, SailmiPIM::Plugin::DocView::Dik::Plugin);

